package yl.hs.bmipfull.viewmodels.WeightApp;

/*
 * SerialPortDevice
 * @category
 * @author 谢景广
 * @date 2022-04-12
 */
public class SerialPortDevice {
    private String deviceName;
    private String portName;
    private int baudRate;
    private int dataBits;
    private Parity parity = Parity.None;
    private StopBits stopBit = StopBits.One;
    private boolean enabled;
    private Integer startIndex;
    private Integer dataLenght;
    private Boolean isReverse;
    private Integer weighModel;
    private Integer dataUnit;

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getPortName() {
        return portName;
    }

    public void setPortName(String portName) {
        this.portName = portName;
    }

    public int getBaudRate() {
        return baudRate;
    }

    public void setBaudRate(int baudRate) {
        this.baudRate = baudRate;
    }

    public int getDataBits() {
        return dataBits;
    }

    public void setDataBits(int dataBits) {
        this.dataBits = dataBits;
    }

    public Parity getParity() {
        return parity;
    }

    public void setParity(Parity parity) {
        this.parity = parity;
    }
    public void setParity(int parity) {
       switch (parity){
           case 0:
               this.parity = Parity.None;
               break;
           case 1:
               this.parity = Parity.Odd;
               break;
           case 2:
               this.parity = Parity.Even;
               break;
           case 3:
               this.parity = Parity.Mark;
               break;
           case 4:
               this.parity = Parity.Space;
               break;
       }
    }

    public StopBits getStopBit() {
        return stopBit;
    }

    public void setStopBit(StopBits stopBit) {
        this.stopBit = stopBit;
    }
    public void setStopBit(int stopBit) {
        switch (stopBit){
            case 0:
                this.stopBit = StopBits.None;
                break;
            case 1:
                this.stopBit = StopBits.One;
                break;
            case 2:
                this.stopBit = StopBits.OnePointFive;
                break;
            case 3:
                this.stopBit = StopBits.Two;
                break;
        }
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Integer getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    public Integer getDataLenght() {
        return dataLenght;
    }

    public void setDataLenght(Integer dataLenght) {
        this.dataLenght = dataLenght;
    }

    public Boolean getReverse() {
        return isReverse;
    }

    public void setReverse(Boolean reverse) {
        isReverse = reverse;
    }

    public Integer getWeighModel() {
        return weighModel;
    }

    public void setWeighModel(Integer weighModel) {
        this.weighModel = weighModel;
    }

    public Integer getDataUnit() {
        return dataUnit;
    }

    public void setDataUnit(Integer dataUnit) {
        this.dataUnit = dataUnit;
    }
}
